//
//  UserViewController.m
//  UI_APP_Project_Bean
//
//  Created by dllo on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UserViewController.h"
#import "LogViewController.h"


@interface UserViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain)NSArray *wordsArray;

@end

@implementation UserViewController

- (void)dealloc
{
    [_wordsArray release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self config];
    
    [self handleData];
    [self creatTableView];
}

-(void)config{
    self.navigationItem.title = @"用户";
    self.wordsArray = [NSArray array];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注销" style:UIBarButtonItemStylePlain target:self action:@selector(zhuxiao:)];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.37 green:0.6 blue:0.7 alpha:1];
    self.automaticallyAdjustsScrollViewInsets = NO;
}


-(void)zhuxiao:(UIBarButtonItem *)bar{
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否确认注销" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        LogViewController *logVC = [[LogViewController alloc]init];
        [self.navigationController pushViewController:logVC animated:YES];
        
        
    }];
    
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    
    [alert addAction:action];
    [alert addAction:action2];

    [self presentViewController:alert animated:YES completion:^{
        
        
        
    }];

    
    
}




-(void)handleData{
    self.wordsArray = @[@"我的活动", @"我的电影", @"清除缓存"];
    
}

-(void)creatTableView{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64)];
    
    
    [self.view addSubview:tableView];
    [tableView release];
    
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"lastCell"];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.wordsArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"lastCell"];
    
    cell.textLabel.text = [self.wordsArray objectAtIndex:indexPath.row];
    
    return cell;
    
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
